package com.xhwl.data.controller;

import com.xhwl.common.dto.cent.sdata.RegionDTO;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Region;
import com.xhwl.common.query.RegionQuery;
import com.xhwl.data.service.IRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: luyi
 * @Description:
 * @Date: Create in 14:37 2021/1/17
 */
@RestController
public class RegionController {

    @Autowired
    private IRegionService regionService;

    @RequestMapping(value = "/region/tree", method = RequestMethod.POST)
    public ResultJson regionMap(@RequestBody RegionQuery regionQuery){
        List<RegionDTO> tree = regionService.tree(regionQuery);
        return ResultJson.success(tree);
    }

    @RequestMapping(value = "/region/list", method = RequestMethod.POST)
    public ResultJson list(@RequestBody RegionQuery regionQuery){
        List<Region> list = regionService.list(regionQuery);
        return ResultJson.success(list);
    }
}
